package com.boot.shiro.dao;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import com.boot.business.demo.entity.User;
import com.boot.shiro.entity.Menu;
@Mapper
public interface MenuDao extends JpaRepository<Menu, String> {
	User findByName(String name);
//	User findByUsername(String username);
//
//	User findByTelephone(String telephone);
//
//	User findByNameAndUsername(String name, Integer age);

	@Query("from Menu u where u.name=:name")
	Menu findMenu(@Param("name") String name);

//	@Results({ //2
//		@Result(property = "id", column = "telephone"), //2
//		@Result(property = "username", column = "username"),
//		@Result(property = "telephone", column = "telephone")
//	})
	
//	@Select("SELECT * FROM sys_menu WHERE telephone = #{phone}") //3
//	List<Menu> get(String phone);
//
//	@Insert("INSERT INTO sys_menu(username, telephone) VALUES (#{username}, #{telephone})") //3
//	void insert(Menu user);
	
	@Select("SELECT m.url FROM sys_menu m WHERE id in(select menu_id sys_role_menus where role_id=#{id})") //3
	List<String> getUrlById(String id);
}
